Added improved comments (from Oisin), fixed a couple of minor bugs.