Change the way to rank results. Clean up old codes