Cleaned up and de-duplicated ranklist-related code

Follow-up to 6cf032d. Special thanks to Ind.

Signed-off-by: Haru <haru@dotalux.com>