MDI code continued.

continuation of MDI part