Improve text viewer and simplify code.