Fix infinite loop on null

Closes #5.