added cachedbyKeySTM, inproved memoization