Adds a better query contraints support.
Fixes some bugs.
Refactoring config module.