tweak pretty printing, handling of non-list input
clean up, add comments
clean up, add comments