removed a case of unnecessary cloning and got rid of the global lock variable