Encapsulate CNameDB interface and improve name_list.

This patch contains some preparations for nameindex pruning.  It restructures the CNameDB interface (to make internals better encapsulated) and it changes the name_list implementation yet again.  This should (potentially) make name_list again a bit faster.  I'd like to get this tested and merged before continuing with nameindex pruning.