added text stream class for writing text
small tweaks and fixes