This is what I finally submitted - it has a few kinks ironed out, and
most importantly, it passed the time limit.