I also ran into a small issue if authors was undefined. Checking for the existance of authors seemed to help
if($hit->Authors)
$Authors = implode(" and ", $hit->Authors);
I also noticed that the results of the query were stored in $books at first and then jumped to being stored in $hits.
if($hit->Authors)
$Authors = implode(" and ", $hit->Authors);
I also noticed that the results of the query were stored in $books at first and then jumped to being stored in $hits.