Fix peculiar bugs introduced by 5bd568d1