Tweaks to MD driver.
Major refactoring to improve KPM API