Changed the way checking for undefined is done due to this: http://jsperf.com/undefchecks/2