Uncaught exception fix in packetwriter