IE fixes, code refactor, error handling