Rewrite Mat formatting without std streams
Finalize core headers reorganization