Fix crash seen in issue 19

Fixes #19