FIX bugs with outputing