Fixing some bugs found while testing on IE10, Chrome 26, Firefox 22