Lots of bug fixes after unit testing with IE11

Still have a lot more tests to write.