Fix data cache

There were some issues related to data cache invalidation. Please read the extensive commit message in 	b9b6350

Could potentially be squashed into a single commit if you prefer.