Fix formatting
Replace cache with memoize pattern
Optimize imports