Added traits to contain formatting code and added types array to cast output to
a type