Code review and some refactoring.