Feature memoization

Added memoization as an optional performance setting
http://en.wikipedia.org/wiki/Memoization