Fix reassignment of context as a result of search-replace
Clean up datasource table before building it