Fixed some issues in text paste handler.