Code refactored and added db.execute()

- The code was refactored for better redability, and perfomance gain
- Added db.execute(), a method for querying the db directly, without having to create a Query() first.