add debugging and exit codes