It's not the best piece of code, it'll work with this version of the Photoswipe script for sure. The problem is that in the carousel class there are no references to the toolbar and/or caption elements.. IIRC. This way I could fetch them anyways.. 
I'll spend a few more minutes to check if I can fix it in another way, but I will probably need to add an extra dependency