An important update to the patch.
If you upgrade from the previous commit, please delete nameindex.dat to force rescan.
There are some additional checks that hurt the performance slightly. We can remove some of them after the hard-fork (150000), if the chain happens to be consistent under a simple set of rules. This is because rules are "transitional" to avoid network fork right now. After the hard-fork we can remove them or simplify to minimal rules that validate the chain up to the block 150k correctly.
I took some minor improvements to ReconstructNameIndex from cjdelisle's patch (full patch still crashes for me for some reason, so I do not merge it for now). Thus if you merge my commit on top of his patch, there may be a few conflicts. Sorry for inconvenience.