Some functional stuff added (Y-combinator and function memoization)