Fixed problems discussed in pull request