Improved implementation of NISupportedInterfaceOrientationsForWindow.

Better traversal of modal controllers.