Transfered from ExMage.