I think it is a bit premature for Mark to take an application that is not quite well defined and a technique that he does not quite understand and combine the two. What I would do is to write all the functions without any templates, and then figure out how they might be simplified using templates.