Some more cleanup and refactorings

* Reformatted long line.
* Refactored ClientHandler to make code more organized
    * Also, easier to write tests for.

[Update] Fixed implicit conversions warning
[Update] Fixed passing `log` around