added support for parameterized queries, better query debugging