Code cleanup

A couple of small cleanups, one of which also contains a fix for a subtle bug