Improving backprop implementation