Modified how a reference to the main controller is retrieved.