Further optimization of LANG-935: - Avoid toString of the replacement sequence by doing it once. - Avoid calculating the maximum when not needed. - Fixup comment for greedy algorithm Thanks to Fabian Lange.