Avoid creating putting LockedConnection instances on the heap when not necessary. Fixes #530.

Also drops the use of format() in favor of formattedWrite() in _request_simple to avoid memory allocations.