Fixed to work with IE8.

Additional minor jslint inspired code improvements