read and write functions closer to completion. Fixed some import errors