Some improvements to cd and selectorFromDOM