Kairos db

Rebased against latest master.