Fix usage of stupid PHP closures. Also, convert some code to use the abstracted caching logic.