New locking, keyGenerator fixes