Fixed database issues