Improve cache and fixes a few bugs!