abort on cancel in save dialog, refactored io code