Database and bug fixes