Full-length code from CRB Nov 2013 talk