add refs caching as per @Carreau's comments