added more caching for likelihood computation