Add missing includes and tidy up