Modified getAllPieces to be more efficient.