Separated out some of the code into different files.