Made some changes as suggested in PR 1882