Some refactoring and little cleanups.
Some code cleanup.
Refactoring.