Fix for Ticket #953 and #871

Only apply to master for now - I may submit a separate request later to apply it to 2.8.1

Thank you