Saving system improvements

This pr improves the saving system by adding a dirty bit to all the resources in the model and saving only those with the dirty bit true.