Changed to exit with correct error code on problems. Stopped logging
Moved removal of work folder to happen before exiting on an error