More refactoring and simplification
Formatting changes