Fix system return code checking