Convert to a more object oriented framework
Remove unnecessary temporary file creation
Convert database for csv handling
Convert command line handling to argparse for robustness