Finished some refactoring.