Fix similarity term bugs and add cache.