moved db to configuration file
fixed function to match mehfildb change
lots of refactoring, some in-place and some to new files