Bit of refactoring and commenting