fixes cache as bitmap, some refactoring