Refactor MD

closes issue #41