Fixed a bug when allocating named objects.