fix NPE introduced in PR #130

also adds nullity annotations to prevent recurrance