Bugs and few changes - in TF cleaning function