added auto-save and fixed minor bugs