Fix derivequeries