A couple fixes suggested by jrick