fixed several double delete bugs