Bits of code from Julie's thesis