PersistentCollection::count() improvements

Supersedes #543.

Added small code changes and documentation updates.