Move some basic algorithms over from older project