added/improved a few warnings
improved choice of database - looks for $DBNAME