Hi,
Sorry, only now I saw your messages… Unfortunately I’m afraid I’m not of great help for you… I manage to have the code working and that’s it… I do not know about debuging issues… I would guess that the first issue is related to the fact that some times you do not have an image (that it also happens for me and I have no issues with the page). As for your second question, I do not have that issue since the type of gallery I’m using does not have preview (I also have some times less images than those I set to display…). As such, maybe you can choose another type of gallery? In any case I’m sure there is a workaround… I simply do not know it.
Good luck!