Fix StackOverflow with big charcoal pits.

Improve performance of the charcoal pit algorithm.