Major restructuring of program,
now based upon derived types