I believe I've solved the problem. I'll check this in and then write additional tests.