major refactor to support sorts in a good way. code is much more logical, and easier to extend.