Fixed misc db bugs.