added cleanup capability to final pass