Automatic memoization

Seems to be some compatibility issues in the closure syntax