Refactoring for mmdemo