Cleaning up some style issues.  Adding a few null checks for safety.