Removed the length argument of endCollection, added the correct length to beginCollection.