refactored softmax layer.