Cleaned up organization of code