cleanups and few more helpers and json db stuff.