More consistent key length decoding