Fixed  #3166 and #3164.