Add and clean-up null-checks.

Change-Id: I4af4c6c3342f19cfc93a27c42ff150818c812e2b
Merge branch 'master' into nullchecks
Merge pull request #85 from mathieu-wang/nullchecks

Add and clean-up null-checks.