Fixed dead-lock when closing tunnels.
Removed unused codes.
Fixed delayed remove pattern to avoid dead-locks.