Your attempt is good, but looks like implementation failed a bit... :)

Perhaps it is worth splitting into several posts - or even putting to some small blog... Did not you consider this idea?