Issue 10086 & 10857 - Adjust instantiated template process order, and fix ICE in glue.c

[Issue 10086](http://d.puremagic.com/issues/show_bug.cgi?id=10086) - ICE(glue.c) or wrong code on passing variable as template value parameter
[Issue 10857](http://d.puremagic.com/issues/show_bug.cgi?id=10857) - ICE(glue.c,　bugzilla 2962?) or compiles, depending on the files order