improoved save engine and added save dialog on exit