Make the code friendlier for monkey-patching for IPython.