Fixes crash in #505
Merge pull request #508 from hilburn/master

Fixes crash in #505