Fixed the "Unresolved index-key value" error.

Refine the algorithms to get $lastTopicRef in bookmap.