revising bad code in template.php causing book pages to break