added proper debug support. can be run in debug mode by setting it on the db connection