Refactor bookmarks code a bit from upstream, specifically fixes #627

Adds some initial work for displaying symbolic icons for bookmarks (like
in the sidebar) but no actual implementation yet.
Merge pull request #629 from mtwebster/bookmarks-627

Refactor bookmarks code a bit from upstream