Still working on an implementation. I have the distinct feeling that I am going about this in a braindead manner.