Refactor term vector creation