Added mongo db with basic support for saving stats
refactoring