Added internal sorting (for Mac OS now but option activate in the future). Minor changes to scripts