Copied functions from IPython Notebook on Revisions