Fix ranking function
Fix sql error in accessing user's rank
Fix bug