updated free to release correct number of elements.