Fixed database problems