Fixed some db issues