optimize localInstancesOfObjects

• check for empty array
• create new array with correct size