Here's a patch to fix these problems. Comments and suggestions welcome. Mark