some fixes. added cache cleaning function