Query builder #1

Added query builder and some comments over the whole code.