fix an issue onsave and cleanups