Added code to support book view, cleaned up code a bit