Tidy up some code
Many minor tweaks from automated suggestions