Bugfix: query prefix was not always derived correctly