Fix $template and $db assignment as it's a leftover from the previous changes.
Add missing request var definition.