Tcp input fixes

This should fix #86 and some of #84.  It seems like sometimes when the listener goes back to the read TCP buffer some of the previous message is still there but this patch really helps.