Fix wchan implementation, based on earlier by from Atsushi Nemoto.