decodePayload() should properly handle eof now but there is another issue with generatepayload()