- Patch #394594 by Berdir: additional conversion to the new database abstraction layer plus clean-up.