Added caching to commonly used functions to improve performance