moved file handling to mdp.c completely