Minor refactoring and equalization with petes branch