nullcheck
scripted update of code from master at fd2170a nullcheck