Forward-port of recent spray patches

This PR aggregates a number of patches that we have applied to spray this week.
ok, will fix.