Refactoring and style updates