KMP and prefix function algorithms updated to more readable