Initial work on correctly returning error status codes