A minor bugfix, a minor speedup, and a bit of code cleanup