added saving of data + bug fixes