Added better string length handling.