Review, test, and fix up algorithm implementation