Fix integrate function to work with our cache