partially fixed database connection and interaction bugs