LPS-32831 revert changes to Site Templates Optimization

As agreed with @mhan810 by email, in order to make bug fixings in Site Templates backportable to previous versions, his latest changes to improve performance will be reverted. This also fixes 10 broken tests.