Added extra 'undefined' check for safari.
Don't ask me why, try the nearest lamppost, you'll get a more coherent answer
out of it than you get out of my magic javascript book.
Got rid of some jshint warnings.

Lots of warnings left on line 69, though.
Merge remote-tracking branch 'origin/master'