Tristan's weighting scheme edits
optimizations