Some basic algorithms.