Decorator memory reduction backport

new pull request