Add flag for enabling/disabling expression caching.

This also checks the global optimization flag.

Additionally, reduce some logging and catch import errors
when serializing.
Merge pull request #143 from spartan-array/cache_optimization

Add flag for enabling/disabling expression caching.