Implemented amortised KMP string matching.