@change:
more management memory in the cosine and local sim functions