Added saving of weights.