fixed a few bugs, tweaked things to work better with sql-server, and added better database connection tracking (so if you have tables in different databases with the same name, the query goes to the correct one)