Optimize mdapt.