Improve rank algorithm more.