Did some refactoring.