Fix caching with foreign rules