CODE: Refactor MagicStone.