Possible fix for #591, needs to be tested on a mac

@dgossow , can you please test this on your mac where you saw #591?

I think it should fix it.  Description in the comment in the code.