Fixes suggested by David Rowley