Style tweaks and refactoring