end could be negative.
Eliminate unused intermediate functions.