Bug fixes and trying to get DB to work