Refactoring.

Some minor refactoring and cleanup.