added argparse, cleaned up splitting logic.