Restructure output generation.