Major cleanup in MediaImpl