fixed several database issues