Added some null and undefined checks

Moved a few boolean checks into variables because they were being used a
whole lot.  Just making things look cleaner.

Fixed a copy/pasta error where the null check and the undefined check
were on different variables.