Rewrote sweep_script to include the class sweepController which does all the work. This makes it easier to understand and easier to import into future programs.