Refs #31, changes positional to named parameters in queries and fixes other bugs.