Fixed the double delete problem remaining in issue 503.