Fix bugs after shuffling