Fixed some database implementation issues.