Minor refactoring.
Code cleanup and refactoring.