Huge bug fixed in template engine core.

New algorithm has been used in tag positions reindexer in the template compiler, so the template syntax checker will working as it should be.