Moved code to conform to more modular file structure