Remove the unused code I noticed when working on d6e80578fc5e and do some other minor cleanups in the vicinity.