Algorithm cleanup