Some minor refactoring done.