BUGFIX: memoization was broken when defining vars in terms of others