Client stubs need to be created at function declaration time
Also support user casts of references
Improve robustness of client stubs body generation