only emit trampolines we need, and other small fixes