Renamed and documented some functions.