Fix management of dynamically allocated loop resources.