Decouple rendering and flattening of Rule datatype

IMO this makes it somewhat clearer what's going on.

I think this decoupling is also a prerequisite to optimizations such as de-duplication of rules.