added support for database export to files, refactoring
minor refactoring