Added clearer range checks for string class to help compiler