Revert "rewrote these two functions with better self-caching"

This reverts commit 40248f1178ee87072450c5881bd3c4cf31db33c4.