Improve search/replace and html encoder