Fixed memory leak in Collection class with a new implementation.

#478 - memory consumption optimized from 12,377,160 bytes to 6,053,976.