[FIX] Various formatting / refactoring and code style cleanup