bug in entity cleanup for SAX serialization compatibility