Clarified Copyright/License
Restructured code into several functions
Cleaned up the main loop , outlined logic for calling external commands