Ie8 fixes

Fixes a couple of issues which were causing all scripts to break in IE8.