fixes #301 but needs lots more testing

this should fix #301 
But there is other oddness with random test failures which I don't think are related.