Finished refactoring the code, for now.