Finished the generic implementation of the stable algorithm