Added db constants and reorganized it a bit