simple implementation of thread local caching, but need to update Makefile appropriately