Fix error based on double precision with max(net) when computing output vector with softmax. Refactor some code.