revised CSV output
minor fixes
some work on templating for xhtml output