This looks a lot like what's in InstrumentPlan.  Can the code be shared?