implemented better locking scheme -- more perf improvements