Fix cleanup code