Primary resource codes and cleanup