Fix for issues #3931 and #3932

Created a new branch to clean up previous pull request.