Added better mime handling