Improved query tokenisation

Use Friedl's "unrolled loop" pattern to avoid incorrect placeholder
detection
Removed pointless docblocks from constants