Better text handling
Improve invalidate function