Minor changes and refactoring.