How does MPPT algorithm and 2-stage battery charging go together?
When a battery is below its final charging voltage, you charge it in constant current mode (CC) mode. The maximum current you should give it will be given on the data sheet. If it doesn't say, then C/10 should be fairly safe for any battery. Some batteries can be charged much faster. This limits the maximum power a battery can accept in this mode.

When the battery has reached its final charging voltage, you charge it in constant voltage (CV) mode. There are two ways to do this. The first is to switch to a voltage regulator. The second is to keep supplying a controlled current, but reduce that current so the voltage does not exceed the final charge voltage. As the current falls, the battery will be accepting much less charge power than in CC mode.

If the battery can accept more charge power than your panel can generate, then you can use the standard MPPT algorithm. Adjust the PWM until the current sent to the battery is maximised.

If the battery cannot accept all the power the panel generates, then you must use something other than MPPT. Adjust the PWM to get a current limited by the max CC charge rate, or the CV mode final charge voltage.