Moved cache to SDK. Fixed some minor bugs.