Added better mime type detection