formatting and whitespace changes, slight refactoring