Minor source reorganization; few dangerous C functions replaced with safer std:: alternatives