fix some errors and refactor kwic2