Additional refactoring according to Doug's comments