heavy refactor and rewrite

complete rewrite for html output
line by line reading instead of bulk
text output still uses old code, change when LDAP asks for it