Moved Mime logic to a new class and cleaned/refactored the logic.