Improvements to MIME type detection