cleanup and fix bugs in ranker: did not work at all, write a test for it