Refactored softmax.