Genericised TableFormatter and added a few for-each loops