Reorganize main app structure to perform main init functions from query on loaded event.