         let container = transitionContext.containerView()
         let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
         let toView = transitionContext.viewForKey(UITransitionContextToViewKey)!
-        let fromController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!
-        let toController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!
+        let fromController = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey)!.topMostViewController()
+        let toController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)!.topMostViewController()
         
         let duration = self.transitionDuration(transitionContext)
         

        
        let alpha: CGFloat = 0.1
        let offScreenBottom = CGAffineTransformMakeTranslation(0, container.frame.height)

        // Prepare header
        let headerTo = (toController as! MCMHeaderAnimatedDelegate).headerView()
        let headerFrom = (fromController as! MCMHeaderAnimatedDelegate).headerView()
        
        if self.transitionMode == .Present {
            self.headerToFrame = headerTo.superview!.convertRect(headerTo.frame, toView: nil)
            self.headerFromFrame = headerFrom.superview!.convertRect(headerFrom.frame, toView: nil)
        }
        
        headerFrom.alpha = 0
        headerTo.alpha = 0
        let headerIntermediate = (fromController as! MCMHeaderAnimatedDelegate).headerCopy(headerFrom)
        headerIntermediate.frame = self.transitionMode == .Present ? self.headerFromFrame : self.headerToFrame
        
        if self.transitionMode == .Present {
            toView.transform = offScreenBottom
            
            container.addSubview(fromView)
            container.addSubview(toView)
            container.addSubview(headerIntermediate)

            container.addSubview(headerIntermediate)
        }
        
        UIView.animateWithDuration(duration, delay: 0.0, options: nil, animations: {
            if self.mode == .Present {
                fromView.alpha = alpha
                toView.transform = CGAffineTransformIdentity
                headerIntermediate.frame = self.headerToFrame
