Fixed optional IPython imports.
Added debug statements