Refactoring and cosmetic enhancements