Sorting works; improvements to finalize; general cleanup