updated script to include additional processing/filtering options, and moved major functions into optional subroutines