address code review comments from PR #646, ref #645, #314, #640