Fixes for normalizing local text and fix query tokenization

See tickets #31 and #33.