Improved deletion code