fix #1448, fix #1566, work on #1585
work on #1382
work on  #1382