Some fixes suggested by @claresloggett