Book formatter: Do not insert last page if it's empty, code cleanup