Moved a = layer.attributes out of the loop and made more meaningful.
Changed overlay handling so failed layer retrieval doesn't prevent anything else from displaying.