support ledgers in cloudcare

also a fairly substantial cleanup of the case database stuff