Mimetype handling refactoring.