It works!!!

Slower than I would have expected for C++, though. I wonder if I'm
deepcopying large arrays somewhere and don't realize it. Probably not
worth the time at this stage to track down though.