adding better cleanup of processes