Return nil where pointers are expected

Fixes #2790