Add save and close button, and fix a bug