Main function is pulled up. Imports reordered.