Replace clear in favor of swap
Re-org tree construction to make it easier to adapt for more processors in the future.
clean up
Fix partition construction.