Enhanced clean and decode functions