Simple (but hopefully clean) implementation of backpropagation.