Implement grid object
Add Q library
Refactor into db and model classes