Added saving diagrams in xml and more improvements