Implemented MongoDBRepository and some refactoring