bunch of improvements

need to copy to my laptop to work on the computer.
array.argsort is buggy.