replace binarysearcharray with std::vector and std::lower_bound
remove unnecessary strlen() and provide more tests for escape()
move middle_t::cleanup code into destructor

Fixes a whole bunch of leaking postgres connections.