added get last error and cleanup for name allocation