Refactor XPath compilation to fix issue #143.