Add more specific error codes and handling of exit status.
Figured out the combination of flex_bg flags that work.