code cleanup; allow saving plots to files
code cleanup