Some patches to (partially) support templated functions. Makes global_var.cpp
test pass.