Improved native query support

Change-Id: I4e21fa4e25c8897825987060c03fe3489a980940