IE compatibility fixes

Fixed some compatibility issues with IE. Note that there is still an "Out of stack space" error in IE9 when attempting to send a message, but I haven't been able to track this down so far.