Finish refactoring and cleaning code.