bugfix and implement cache_writes properly