Fix 2 potential crashes

(1) Race condition caching data
(2) When no writer or cast data available