Check for nil pointer. Fixes #20