Robustify code to missing values. Fixes #3