Move to rational Fractions instead of reals, and implement faster AC matching using KMP