Improved the way error codes are passed through functions.