Null Reference Exception checking, minor changes

Hyper-paranoid Null Reference Exception checking, minor optimizations
and redundancy removal.  Some cleanup.