Fix indent level.
Replace gallery id with the id generated client-side.

Because we are fetching the output of the gallery shorcode one-by-one, the
index is not incremented, so we need to use the identifier generated client
side.
Clean up some debug statements.