Implement the main script and function

The main driver function and stand alone script has been implemented,
pending testing.