Cleanup

Cleaning up some of the flow. Modifying some of the function arguments and return values. Modify the utilities and logging files.