added file save dialog and cleaned up structure