The suddenly varying light and indefinite focus of fireworks can be quite tricky. I messed around a lot with them one night shortly after getting my G2.
I found 400 ISO wasn't worth it, 200 could be okay, but I actually far preferred photos at 100 or 50 even if the shutter had to stay open longer.
If you were on your P setting, as you said, you weren't able to control shutter speed and aperture manually.
Aperture does need to be set to infinite, and you can thereafter mess with manually adjusting exposure times depending on your exact ISO, desires, and so on. You don't want the camera trying to figure things out automatically.
Tripod/stability will be necessary, of course.
You also might want to use your infrared control to minimize camera shake, and consider disabling the 2-10 second auto-review so the camera can recover faster (it can already take about as much time to get ready again as the shutter stays open).
Anyway, it can be good to "play in traffic" (from a distance) and so on to get prepped before trying fireworks themselves.
Given that your best photos will happen if the shutter's already open slightly before something even explodes, they can be one of the toughest things to shoot well.