Edited Mage.php for MWI plugin