Fixed writing of weights