Implementation of basic algorithms.