Fix some bugs when loaning a book.