Improve handling of different media types