Rational Codes and Free Profinite Monoids