Prevent Warnings by checking for empty()

I added some code so that it would run okay with warnings enabled.  Mostly it consists of changing 

   if ($var)

to 
 
  if (!empty($var))

so that if $var doesn't exist, it doesn't throw a warning.