fixed possible race condition in hydrate, as well as a lock issue when hydrate+cache was used