Porting stable over from GNUstep. + minor changes.