Bug fix for textbook browser. optimization for user profile

fix bug that caused server error when viewing browser and not signed in
Reduce number of database queries when viewing user profile.