remove bashism from POSIX shell script
close temp files
Misc tidying
autopep8 on webui.py
lots of autopep8 and tidying