Fix issues with (intra-region) sorting, additional cleanup of JS