make it compile with clang

Basically that means avoiding cyclic class usages. This code makes
your head spin. Having said that, it only makes the current situation
quantitatively worse not qualitatively...