Cache refactored, full implementation added