Rewrite a lot of the template trampoline generation.

The code is much cleaner, and it avoids calling functions through O(n)
lambda-closure/std::function wrappers for a target with n arguments.