Reworked script

- Consolidated code into single file
- Moved settings to the top
- Added log function
- Added some error handling
- Cleaned up some unnecessary output