Code from  lectures 2013-06-04 and 2013-06-11