Updated to allow proper exit codes