Fixed the magic API.
Updated to use the magic api object.
Minor simplification.