put much of the processline routines into individual functions; did not remove any extraneous comments