Algorithm now appears to be working.  Next step is to print out some statistics.