Minor refactoring and comments. Smaller footprint