Reimplemented code that takes care of handling database changes.
Authored by: delphidabbler 2011-11-09
Parent: [r1718]
Child: [r1720]