Some improvements to depth-first search