Reorganized to reduce duplication using ideas in the lammps_parser code.