Fix allowing selector to end with '>'; Add framework for simplifying selector graph