* Handle alias table name properly
* Added query property
* Added dirty method and return cached query
* Added param for flatten and cleaned up unused code