General cleanup / WIP commit.
WIP commit, added memoization caching.