Fix build issue and ref count bug with scripts.
3 files changed