Some refactoring done.