Minor refactoring and some alterations.