Final versions of all algorithms