Tidy up some imports and removed code moved elsewhere
Switch over to using an io-streams interface