fix some real db bugs