Check/cache value before using it in  to avoid index not set errors.
Merge pull request #20 from kenguest/master

Check/cache value before using it in  to avoid index not set errors (that are logged to system.log file).