Fixed a bug on error codes and a bug on path handling