Slight refactoring and cosmetic changes