Collections inside Collections - JS problem

Adopted the changes from #464 and #355 to the master branch.

Credits go to @naitsirch and @byhoratiss.