Fix most "trouble in init_rank" bugs