fix some database related issue