add a few typeasserts for additional clarity, and protect against malformed XPaths