Updated style, general refactoring