Fixes to plotting, added code to save log to file and other fixes