Changes for IE compatibility
Some work on error handling