several bugs corrections