fixes bugs in template
Fixes bug where rebuilding would hold values from first call