Fixed weight calculation. Improved optimisation. Batch testing.