Corrected some bugs in MD