Remove num_pieces global variable