added Mongolog support and major refactoring