CS fixes and a bit of refactoring to improve readability

Actually, that's true for a lot of things. Better leave that for a different pull.