Added priority sort and some locale refactor