Merged in Alans latest code, fixed a bug on entity load in the tei_editor.