Further formatter work

This pr aims to further improve the formatter.
It's far from done so please don't merge it until I remove the [WIP] label.


Thanks.