Minor code cleanup

A follow-up to our discussion on Twitter.
It's not complete, but shows several points for code improvements.

You may disagree on some aspects, so feel free to discard them or ask for details :)