PAHMA-1131: correct restricted query; other small tweaks