Fixed bug mentioned in issue #886 #865 #862