Finished refactoring old code.