Clean up and organize code