Migrated err to thread-local.
Renamed context to pool.
Renamed env to ctx.