Adding a lock to the conn so that closes don't collide with writes