Added some "just-to-make-sure" null pointer checks even though it should be safe now.