Implemented optimizations for the cosine distance in cython; now down to 1us from 14