Implementation of some algorithms.