Fix 1127 in master

This is my fix for #1127 in master, corresponding to #1141.