Revert "Update prototype and fix template evaluation bug"

This reverts commit ddd8443d5fc13675faf4cfcee45f30fab8ba8007.
Protect against script errors