Cleaner fix from @mtdownling