Just finished re-factoring Optimus into smarter subroutines. The plan is to create something that can be used as a solo script or as an object in an MA platform. Before I add procedural crap, I thought I'd dump the methods themselves uncluttered. May as well be here:
(Untested, typos abound):
http://pastebin.com/itbPS1Au