BZ-12137 and BZ-12063: chnages to clean the model before saving it, and changes to fix issue calculating the max saving per category