Began to refactor code to make it more modular