A few optimizations and fix for memory leak caused by collection.getLength()