Fix: correctly handle connections with stuff remaining at the end