Some changes and refactoring.