Clean up the main() function