This method is full of patches to make IE happy, and to keep legacy tests passing. A better approach should be considered.