Refactored code to consolidate common functions in common.py, and other changes

Added better error checking to simple_search
Added proper argument parsing to simple_search
Added automatic API key loading