UP-3654:  Merging fix submitted by jameswennmacher in pull request #113, plus a couple tweaks