Properly handling cleanup phase