core cleanup code fixed