Adding memonize

Fixes #47  But its not completely done. Need to test with Beta 3 as the Swift compiler hogs a lot of memory and doesn't compile and run tests.