Further refactoring/cleanup.