fixed termination bug and lambda reference to a single uid bug