Implemented text export

and various minor improvements