(1) adding #ifdef __RWSTD to make sun compiler happy (2) fix pair density calculation problem when two selections intersect with each other