Some more algorithim cleanup