Improving nil handling

Fixes #3