Refactors and adds error handling
Adds deducing if applescript file is passed
Improves documentation