Better error handling + now only codes are returned for errors and messages are returned