A few changes to #451 suggested by megawac