Full code as used for CoLab demonstration April 2012