Correction for bugs #77 and #65. Hopefully the last.