Final version of my code (including iPython Notebook).