Improve native query creation #633