Fixes for random packet length encoding