add streaming mmd, refactor linear time mmd