refactored code to use argparse. added help and usage info. broke apply_rules into components