Export Redis DB to JSON.

It's a bit of a hack and needs some cleaning up and optimization, but
it works.
Remove some dead code.