After looking at the script, couldn't it all be done in-formula? This would allow for community contributions.