Restructure format, add group and flatten
Add test cases for format
Add color code in format.cpp to test how it looks on terminal