Starting of massive refactors and add session storage

Start refactor request filtering, extract Query to external module.
This version is not functional.