161

@avsm please review. I've left some comments about the cause of this issue in #161

The fix isn't pretty but it seems to work fine.