I have found the problem! The indexer used the status of the post, which wouldn't change, instead of the status in the loop. Except for the last status, it always removed the book from the "shelf".