Removed `die` from script and added proper exit codes