[mod] clean up query expansion code