Refactored mimetype and renamed functions.