improved error codes and msgs