scaled grad, better initialization of Z, small fixes