Fix for #986
Fix for #991
Fix for #993