Minor changes; started moving SQL code to Python
Moved all old SQL code into Python