Added program exit statements when errors occur.