Add nullness and correct value checks, fixes #2