saveAndExit function is reimplemented.
Main test program is changed.
TODO comment is removed.