Move media manager code to different file