support for mongodb and major refactoring of code base