major updates

identified numerous errors,

there is still a problem with the adjusted weights and ordering,

fixed inefficient sorting, is now n logn