pointer cache: fixed double free
cache and core: set pointer to NULL after free
Merge pull request #1328 from bmiklautz/misc_fixes_20130628

Misc fixes