Yep, most definitely replace that plastic pos, and consider yourself very fortunate that it didn't leak and cause an overheated engine.

Remove the 2 bolts and the 2 hoses - use a shallow pan or rags to catch the coolant. Clean the mounting area of the engine of any old gasket or deposits.

The metal housing will be in 2 sections - be careful not to change the orientation of the t-stat if you take it out of the housing. If the metal part doesn't come with a new gasket included, buy a new gasket. Also buy 2 small size worm-gear clamps to replace the factory spring hose clamps.

Line up the metal t-stat housing to the mounting area, checking that the gasket is in the correct spot (no gasket sealer is necessary). Thread the bolts in by hand at first, in order to make certain they're not cross-threading, and check that the housing is seating properly. This can be a bit of a PITA because of the cramped working space and the 2-piece housing.

When you're sure it's seated correctly, tighten in stages to a final torque of 15 ft lbs. Attach the 2 hoses to the housing with the worm-gear clamps. These hoses may weep at the clamps, and need to be checked for a few days and tightened as necessary.
A good way to do this is with the fingers of one hand covered by a nitrite/latex glove, checking the underside of the hoses.

Fill the tank with coolant up to the top mark, set the heater on high, start it up and idle for 10-15 minutes with the tank cap off. Add coolant as necessary. Aveos burp air easily, but still monitor the temp gauge and coolant level closely for a few weeks.