Misc tidying, and fix for image autorefresh