Fix #905: Caching generates invalid group values in some cases