Tweaked return code handling to use the usual Python method