Fix color problems when switching books; refactor some color mgmt code
Add some comments