Refactored text/Unicode handling.