Only txn_commit in read-write mode.

Don't txn_commit a DB on close if it was in read-only mode.
Performance optimisations of nameindex rescan.

Optimise performance of nameindex rescan by removing the need to load
the full tx (tx index is enough) except for game tx and by constructing
the index in memory and writing it down to disk only at the very end.