Drastically simplified memoization implementation by removing redundant declarations