minor bug fix
initialize lock before exit; fix id