fixed some bugs related to dead-ends