Minor logic fixes

Fixed a couple of things, but caching still doesn't work.