Implementations of various algorithms.