fix cache bugs, make bundleable