Fixed scripts in palette running after category is switched

Transfer of #145.
Fixes #130.