cleanup of patch structure