Added termination markers to replace DataInputStream.available to see if it fixes crashes