Fix memory leaks in XML documentation