Split out some functions

Split out some functions from the large find_affected_books function to
make the flow easier to understand.

Change-Id: I3fe34d01d0a7277db51ccf5fea0852cd86b59589