Script cache

Added Caching to scripts.
This is a relatively minor stylistic issue, but we prefer the use of NULL over 0