Finished refactoring code. Tests should now be able to be written.