The algorithm seemed unusual and I had spent some effort understanding it, so I thought I'd add a comment.