Fixed the return codes for errors to follow specs.