Cleanup

Cleaning up code before refactoring to modularize the codebase.