Done some refactoring.