optimize some unneeded casts (esp. when casting something to string for array access)