fix some problems related to #337
fix #341
fix intra-page TOC problem #339
cts:query* mapping for #340