Made async queries, prepared queries, and data encoding work (with tests)