TCO for case statements, CAS for JS terms

@garyb Would you please have a look over this? It enables TCO for case statements in a slightly safer way by providing capture-avoiding-substitution for JS terms.