Separated out various functionality into their own files.
Small code cleanup.