Added periodic save to prevent UI from blocking