Better fix for #107

Building on the earlier tempory fix.
Merge pull request #108 from tarsius/master

Better fix for #107