Several refactoring / code cleanup type changes.