Refactored code into multiple files

Commented out some code which will only be used for tests.