complete overhaul of generic algorithms