Fixed an issue in the upstream code.

The new code should not have been in a closure because the entire
library was in a closure.
Optimization via caching variables within render functions.