Further cleanup of platform-dependent S2 code. Also fixed 2847.