Added better error codes, and fixed strdup.
5 files changed