Fixed error code generation and capture, fixed print debugging to be universal