Fix for #1003
Small optimization for #1003
Small optimization when no valid cache is used