Unix return codes, moved functions to top