Finding dead ends and splicing them