fixed a whole slew of issues jshint missed because it wasn't checking for undef ):