Fix unwanted side effects of book variable

From #5421.