Total re-write of structure and routines.