move all db interface to core for replacing kb with transactor later
rewrite most stuff