fix issues with socket.write concatenating multiple payloads