minor things
fixed locking issue in do_lookup
fixed several bugs while looking for worse bugs