Fix #657 and a few other formatting tweaks