Use ctx->client/ctx->session inline instead of temporary variables which were
being reused and causing confusion and problems.

24 files changed