Refactoring and some other changes.