Misc style changes + refactoring