REL-1811: Bug fix NPE.

Correcting some overenthusiastic removal of null checks. Also fixing some raw type warnings to improve my low Karma.