I've done this now, and corrected a bug in the previous code.