Remove nulls from input

Fixes #317.