Fix loop / shuffle bugs