A bug with dynamic variable lookup and templates