mvc/model/query.c optimization

The intention was to replace all hardcoded numbers with the constants from scanner.h but in addition I optimized several methods (only obvious things were optimized and this is why there is still some room for improvement).