minor database changes
bug fixes in database.py, 'collection' is now a local variable