further fixes of scope management