Fix issues mentioned in pull request. Fix #29