Fixes issues #1135, #1141, #1143