Fix database related issues