fixed #1030
fixed #1026
fixed #1023
fixed #1017
fixed #991
worked on #1031