Fix Database Bugs