Improvements for compatibility with iPython Notebook interface.