Below are fixes copied over from PR #136