Fixed string manipulation errors