Fix querylayers

To fix #540