Fixed a bug when creating new diag template. Optimized save routines to only save when dirty