Numerous changes

- Main now stands alone and will work so long as all the arguments provided are valid
- Removed the 'local' designation from some variables as it was causing issues
- Replaced 'duration' with 'samples' as it is more descriptive