Minor Improvements

The most important change is #6c08104 so that when any connection error occurs, we have a chance to clean up all pending queries, including the ongoing one. This works because it's guaranteed that abort or end event has not been fired when such occurs.