Made more memory efficient
Cap the memory usage of initital position sort (at cost of wall-clock time)