Apply fixes suggested by @harding (Thanks!)