fixed possible dataset inconsistency in case of crash