Rebuilding a Porter Cable 18V battery

I have a large collection of 18V Porter Cable tools. The oldest are from 2010, and the batteries are starting to fail. I've heard that Harbor Freight's 18V battery uses the same cells. A new Porter Cable battery is about $40, whereas the Harbor Freight battery, with the ubiquitous 20% off coupon, is just $10.40.

Both batteries open by just removing a few screws. The Porter Cable battery is better packaged, but the layout of the cells is identical:

Side by Side

The main difference is that the Porter Cable battery has a temperature sensor:

Temperature Sensor

I left it attached to the battery connector and untaped it from the old cell. I then disconnected the leads and soldered them to the new battery - black to black, white to red.

Everything checked out:

Voltage

I gave the battery a full charge. and it seems to be working well.