Workaround for MSVC std::function bug
Refactor KeyCache