Updated API to allow more flexible schemas and queries