Fix bugs found in PR #1 review