refactored linear time mmd
memory errors fixed in streaming and linear mmd