introduced references and an internal per call cache
fixed internal caching