Cleanup and sort() fix