Fixed bug in magic_api, fixed bugs in params passed to can buy from set function