Moved more functions to onHidden.