Some minor code refactoring/cleanup.