better parsing of spaces in keypath for closing tags of sections