reworked file cache
refactored
added debug code