More precise path-group check. Closes #964