Clearing the native vs local confusion
The first commit is a clean bugfix, which I think can be backported to stable branches.
The commits that follow it are a comprehensive revision of the conceptual mismatch that was at the core of the bug. The commit messages extensively document each occurrence with references to its backlog.
In the middle of it, there are also some bugfixes and cleanup of run_scripts(). I can split these out into another merge request if needed.
Edited by Ondrej Holy