fix bug with indexing
fix bug in merge pass.
more code comments, simplified partial_sort