Fix edge case with nil values and length tokenization