memo: Fixing the algorithm and basically finalizing it.