Fixes a bug in string length calculation