guards on cache for large strings + misc fixes