Clean Code in Main

This installment has a clean workable main.cpp and added matrix and
grid functionalities for TFI