Refactoring, add graph error graphic generation, better logging.
Add check for stale database file