Fix multiple-packets-in-one-buffer bug that has plauged my code for months