fix comments, check for null in a few places to quiet some code analysis issues