Add thread-safe connection pool

See issue #21.