Fix for issues #3931 and #3932

Created a new branch to clean up previous pull request. 
Right. But i just want to be on safe side.