cleanup and adds caching