Fixed ipython magics to correctly deal with output