Fixes recommended by phinze for #2333