Bug fixes and new algorithm for ranked relevance

...hm for ranking