Added removal of old array elements.