See the Simplification Envelopes page for more information, including publically available source code.