Fixes issues #811, #885, #972, #994