Refactored some code out into a new file/class.