Fix crashes, add a save dialog