Tidy up algorithms