Code from CMPS12B/M F14 at UCSC