Database improvements & additions

Fixed gleez/cms#748
Should be abstract