corrects saving of entities and indentation