Clean up caching, add some new functions, hopefully fix instead of break bits and pieces