Partially completed framework for final algorithm.