refactoring sync engine and mongodb support