A basic outline of the algorithm, and some initial tests.